package HashBuck;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-05-26
 * Time: 16:47
 */
class  Person{
    public String id;

    public Person(String id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(id, person.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    @Override
    public String toString() {
        return "Person{" +
                "id='" + id + '\'' +
                '}';
    }

}
public class Test {
    public static void main(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.push(1,1888);
        hashBuck.push(2,2888);
        hashBuck.push(3,3888);
        hashBuck.push(5,5888);
        hashBuck.push(14,14888);
        hashBuck.push(6,6888);
        hashBuck.push(4,4888);
        hashBuck.push(24, 24888);
        System.out.println(hashBuck.get(1));
        System.out.println(hashBuck.get(2));
        System.out.println(hashBuck.get(14));
        System.out.println(hashBuck.get(23));
    }
    public static void main2(String[] args) {
        Set<String> set = new HashSet<>();
        set.add("hello");
        set.add("nij");
        set.add("hello");
        System.out.println(set);
        set.clear();
        System.out.println(set);
    }
    public static void main1(String[] args) {
        Map<String ,Integer>  map = new TreeMap<>();

        map.put("abc",10);
        map.put("abcd",101);
        map.put("fcd ",1);
        map.put("b",2);
        map.put("he",22);
        System.out.println(map.get("he"));
        System.out.println(map.getOrDefault("haha", 111));
        System.out.println(map);
//      map.remove("he");
//        System.out.println(map.getOrDefault("he", 11));
       Set<String> set =  map.keySet();
        for (String x:  set ) {
            System.out.print(x+" ");
        }
    Collection<Integer> set2 =  map.values();
        for (Integer x: set2 ) {
            System.out.print(x+" ");
        }

       Set<Map.Entry<String , Integer>> set3 = map.entrySet();
        for (Map.Entry<String , Integer> entry : set3 ) {
            System.out.println("key :"+ entry.getKey() + "    value :" +entry.getValue());
        }
    }
}
